// Based on constructInterleavedCrash bug report.
//
#include "libavoid/libavoid.h"
#include <sstream>

void test()
{
	Avoid::ConnEnd end1_0;
	Avoid::ConnEnd end2_0;
	Avoid::Polygon poly0;
	Avoid::Router * router0 = new Avoid::Router(Avoid::OrthogonalRouting);
	Avoid::HyperedgeNewAndDeletedObjectLists newanddeletedobjects_0;
	Avoid::ConnRefList::const_iterator connit_0;
	Avoid::JunctionRefList::const_iterator junctionit_0;
	router0->setTransactionUse(true);
	router0->setRoutingPenalty(Avoid::segmentPenalty);
	router0->setRoutingParameter(Avoid::portDirectionPenalty, 100);
	router0->setRoutingParameter(Avoid::idealNudgingDistance, 25);
	router0->setRoutingOption(Avoid::improveHyperedgeRoutesMovingAddingAndDeletingJunctions, true);
	router0->setRoutingPenalty(Avoid::fixedSharedPathPenalty, 9000);
	router0->setRoutingOption(Avoid::penaliseOrthogonalSharedPathsAtConnEnds, true);
	router0->setRoutingParameter(Avoid::crossingPenalty);
	router0->setRoutingOption(Avoid::performUnifyingNudgingPreprocessingStep, true);
	poly0 = Avoid::Polygon(4);
	poly0.setPoint(0, Avoid::Point(50410, 49975));
	poly0.setPoint(1, Avoid::Point(50410, 50710));
	poly0.setPoint(2, Avoid::Point(49975, 50710));
	poly0.setPoint(3, Avoid::Point(49975, 49975));
	Avoid::ShapeRef * shape0_1023802233 = new Avoid::ShapeRef(router0, poly0, 1023802233);
	Avoid::ShapeConnectionPin * pin0_1023802233_0 = new Avoid::ShapeConnectionPin(shape0_1023802233, 1, 0, 100, false, 10, 4);
	pin0_1023802233_0->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_1 = new Avoid::ShapeConnectionPin(shape0_1023802233, 2, 0, 250, false, 10, 4);
	pin0_1023802233_1->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_2 = new Avoid::ShapeConnectionPin(shape0_1023802233, 3, 0, 550, false, 10, 4);
	pin0_1023802233_2->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_3 = new Avoid::ShapeConnectionPin(shape0_1023802233, 4, 425, 100, false, 10, 8);
	pin0_1023802233_3->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_4 = new Avoid::ShapeConnectionPin(shape0_1023802233, 5, 250, 0, false, 10, 1);
	pin0_1023802233_4->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_5 = new Avoid::ShapeConnectionPin(shape0_1023802233, 6, 425, 250, false, 10, 8);
	pin0_1023802233_5->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_6 = new Avoid::ShapeConnectionPin(shape0_1023802233, 7, 250, 725, false, 10, 2);
	pin0_1023802233_6->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_7 = new Avoid::ShapeConnectionPin(shape0_1023802233, 8, 100, 725, false, 10, 2);
	pin0_1023802233_7->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_8 = new Avoid::ShapeConnectionPin(shape0_1023802233, 9, 100, 0, false, 10, 1);
	pin0_1023802233_8->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_9 = new Avoid::ShapeConnectionPin(shape0_1023802233, 10, 0, 400, false, 10, 4);
	pin0_1023802233_9->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_10 = new Avoid::ShapeConnectionPin(shape0_1023802233, 11, 0, 175, false, 10, 4);
	pin0_1023802233_10->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_11 = new Avoid::ShapeConnectionPin(shape0_1023802233, 12, 0, 325, false, 10, 4);
	pin0_1023802233_11->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_12 = new Avoid::ShapeConnectionPin(shape0_1023802233, 13, 0, 625, false, 10, 4);
	pin0_1023802233_12->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_13 = new Avoid::ShapeConnectionPin(shape0_1023802233, 14, 425, 175, false, 10, 8);
	pin0_1023802233_13->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_14 = new Avoid::ShapeConnectionPin(shape0_1023802233, 15, 325, 0, false, 10, 1);
	pin0_1023802233_14->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_15 = new Avoid::ShapeConnectionPin(shape0_1023802233, 16, 425, 325, false, 10, 8);
	pin0_1023802233_15->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_16 = new Avoid::ShapeConnectionPin(shape0_1023802233, 17, 325, 725, false, 10, 2);
	pin0_1023802233_16->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_17 = new Avoid::ShapeConnectionPin(shape0_1023802233, 18, 175, 725, false, 10, 2);
	pin0_1023802233_17->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_18 = new Avoid::ShapeConnectionPin(shape0_1023802233, 19, 175, 0, false, 10, 1);
	pin0_1023802233_18->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_1023802233_19 = new Avoid::ShapeConnectionPin(shape0_1023802233, 20, 0, 475, false, 10, 4);
	pin0_1023802233_19->setExclusive(true);
	poly0 = Avoid::Polygon(4);
	poly0.setPoint(0, Avoid::Point(49535, 50540));
	poly0.setPoint(1, Avoid::Point(49535, 50650));
	poly0.setPoint(2, Avoid::Point(49415, 50650));
	poly0.setPoint(3, Avoid::Point(49415, 50540));
	Avoid::ShapeRef * shape0_145706592 = new Avoid::ShapeRef(router0, poly0, 145706592);
	Avoid::ShapeConnectionPin * pin0_145706592_0 = new Avoid::ShapeConnectionPin(shape0_145706592, 1, 60, 10, false, 10, 1);
	pin0_145706592_0->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_145706592_1 = new Avoid::ShapeConnectionPin(shape0_145706592, 2, 60, -1, false, 10, 2);
	pin0_145706592_1->setExclusive(true);
	poly0 = Avoid::Polygon(4);
	poly0.setPoint(0, Avoid::Point(49504, 50775));
	poly0.setPoint(1, Avoid::Point(49504, 50860));
	poly0.setPoint(2, Avoid::Point(49446, 50860));
	poly0.setPoint(3, Avoid::Point(49446, 50775));
	Avoid::ShapeRef * shape0_368159034 = new Avoid::ShapeRef(router0, poly0, 368159034);
	Avoid::ShapeConnectionPin * pin0_368159034_0 = new Avoid::ShapeConnectionPin(shape0_368159034, 1, 29, 0, false, 10, 1);
	pin0_368159034_0->setExclusive(true);
	Avoid::JunctionRef * junction0_144230940 = new Avoid::JunctionRef(router0, Avoid::Point(49475, 50725), 144230940);
	junction0_144230940->setPositionFixed(true);
	Avoid::JunctionRef * junction0_526491597 = new Avoid::JunctionRef(router0, Avoid::Point(49600, 50525), 526491597);
	junction0_526491597->setPositionFixed(true);
	Avoid::JunctionRef * junction0_30828132 = new Avoid::JunctionRef(router0, Avoid::Point(49600, 50650), 30828132);
	junction0_30828132->setPositionFixed(true);
	poly0 = Avoid::Polygon(4);
	poly0.setPoint(0, Avoid::Point(50485, 49265));
	poly0.setPoint(1, Avoid::Point(50485, 49550));
	poly0.setPoint(2, Avoid::Point(50190, 49550));
	poly0.setPoint(3, Avoid::Point(50190, 49265));
	Avoid::ShapeRef * shape0_59732242 = new Avoid::ShapeRef(router0, poly0, 59732242);
	Avoid::ShapeConnectionPin * pin0_59732242_0 = new Avoid::ShapeConnectionPin(shape0_59732242, 1, 110, 10, false, 10, 1);
	pin0_59732242_0->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_59732242_1 = new Avoid::ShapeConnectionPin(shape0_59732242, 2, 10, 110, false, 10, 4);
	pin0_59732242_1->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_59732242_2 = new Avoid::ShapeConnectionPin(shape0_59732242, 3, 110, -1, false, 10, 2);
	pin0_59732242_2->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_59732242_3 = new Avoid::ShapeConnectionPin(shape0_59732242, 4, 285, 110, false, 10, 8);
	pin0_59732242_3->setExclusive(true);
	Avoid::ShapeConnectionPin * pin0_59732242_4 = new Avoid::ShapeConnectionPin(shape0_59732242, 5, 285, 185, false, 10, 8);
	pin0_59732242_4->setExclusive(true);
	poly0 = Avoid::Polygon(4);
	poly0.setPoint(0, Avoid::Point(50610, 49646));
	poly0.setPoint(1, Avoid::Point(50610, 49704));
	poly0.setPoint(2, Avoid::Point(50525, 49704));
	poly0.setPoint(3, Avoid::Point(50525, 49646));
	Avoid::ShapeRef * shape0_152071508 = new Avoid::ShapeRef(router0, poly0, 152071508);
	Avoid::ShapeConnectionPin * pin0_152071508_0 = new Avoid::ShapeConnectionPin(shape0_152071508, 1, 0, 29, false, 10, 4);
	pin0_152071508_0->setExclusive(true);
	Avoid::JunctionRef * junction0_24560921 = new Avoid::JunctionRef(router0, Avoid::Point(50300, 49675), 24560921);
	junction0_24560921->setPositionFixed(true);
	end1_0 = Avoid::ConnEnd(shape0_145706592, 2);
	end2_0 = Avoid::ConnEnd(junction0_144230940);
	Avoid::ConnRef * conn0_61425638 = new Avoid::ConnRef(router0, end1_0, end2_0, 61425638);
	end1_0 = Avoid::ConnEnd(junction0_144230940);
	end2_0 = Avoid::ConnEnd(shape0_368159034, 1);
	Avoid::ConnRef * conn0_378385232 = new Avoid::ConnRef(router0, end1_0, end2_0, 378385232);
	end1_0 = Avoid::ConnEnd(Avoid::Point(49975, 50450), 15);
	end2_0 = Avoid::ConnEnd(Avoid::Point(49600, 50525), 15);
	Avoid::ConnRef * conn0_117136925 = new Avoid::ConnRef(router0, end1_0, end2_0, 117136925);
	poly0 = Avoid::PolyLine(3);
	poly0.setPoint(0, Avoid::Point(49975, 50450));
	poly0.setPoint(1, Avoid::Point(49600, 50450));
	poly0.setPoint(2, Avoid::Point(49600, 50525));
	conn0_117136925->setFixedRoute(poly0);
	conn0_117136925->setSourceEndpoint(end1_0);
	conn0_117136925->setDestEndpoint(end2_0);
	end1_0 = Avoid::ConnEnd(shape0_1023802233, 3);
	end2_0 = Avoid::ConnEnd(junction0_526491597);
	Avoid::ConnRef * conn0_224626788 = new Avoid::ConnRef(router0, end1_0, end2_0, 224626788);
	end1_0 = Avoid::ConnEnd(Avoid::Point(49600, 50525), 15);
	end2_0 = Avoid::ConnEnd(Avoid::Point(49600, 50650), 15);
	Avoid::ConnRef * conn0_446423927 = new Avoid::ConnRef(router0, end1_0, end2_0, 446423927);
	poly0 = Avoid::PolyLine(3);
	poly0.setPoint(0, Avoid::Point(49600, 50525));
	poly0.setPoint(1, Avoid::Point(49600, 50587));
	poly0.setPoint(2, Avoid::Point(49600, 50650));
	conn0_446423927->setFixedRoute(poly0);
	conn0_446423927->setSourceEndpoint(end1_0);
	conn0_446423927->setDestEndpoint(end2_0);
	end1_0 = Avoid::ConnEnd(Avoid::Point(49600, 50650), 15);
	end2_0 = Avoid::ConnEnd(Avoid::Point(49475, 50725), 15);
	Avoid::ConnRef * conn0_880789055 = new Avoid::ConnRef(router0, end1_0, end2_0, 880789055);
	poly0 = Avoid::PolyLine(3);
	poly0.setPoint(0, Avoid::Point(49600, 50650));
	poly0.setPoint(1, Avoid::Point(49600, 50725));
	poly0.setPoint(2, Avoid::Point(49475, 50725));
	conn0_880789055->setFixedRoute(poly0);
	conn0_880789055->setSourceEndpoint(end1_0);
	conn0_880789055->setDestEndpoint(end2_0);
	end1_0 = Avoid::ConnEnd(Avoid::Point(49975, 50600), 15);
	end2_0 = Avoid::ConnEnd(Avoid::Point(49600, 50650), 15);
	Avoid::ConnRef * conn0_11189244 = new Avoid::ConnRef(router0, end1_0, end2_0, 11189244);
	poly0 = Avoid::PolyLine(3);
	poly0.setPoint(0, Avoid::Point(49975, 50600));
	poly0.setPoint(1, Avoid::Point(49600, 50600));
	poly0.setPoint(2, Avoid::Point(49600, 50650));
	conn0_11189244->setFixedRoute(poly0);
	conn0_11189244->setSourceEndpoint(end1_0);
	conn0_11189244->setDestEndpoint(end2_0);
	end1_0 = Avoid::ConnEnd(shape0_59732242, 3);
	end2_0 = Avoid::ConnEnd(junction0_24560921);
	Avoid::ConnRef * conn0_605306624 = new Avoid::ConnRef(router0, end1_0, end2_0, 605306624);
	end1_0 = Avoid::ConnEnd(junction0_24560921);
	end2_0 = Avoid::ConnEnd(shape0_1023802233, 15);
	Avoid::ConnRef * conn0_61198110 = new Avoid::ConnRef(router0, end1_0, end2_0, 61198110);
	end1_0 = Avoid::ConnEnd(shape0_1023802233, 19);
	end2_0 = Avoid::ConnEnd(junction0_24560921);
	Avoid::ConnRef * conn0_323306544 = new Avoid::ConnRef(router0, end1_0, end2_0, 323306544);
	end1_0 = Avoid::ConnEnd(shape0_152071508, 1);
	end2_0 = Avoid::ConnEnd(junction0_24560921);
	Avoid::ConnRef * conn0_2415000 = new Avoid::ConnRef(router0, end1_0, end2_0, 2415000);
	router0->processTransaction();

	newanddeletedobjects_0 = router0->newAndDeletedObjectListsFromHyperedgeImprovement();
	router0->outputDiagram("output/treeRootCrash02-1");
	end2_0 = Avoid::ConnEnd(junction0_144230940);
	conn0_61425638->setDestEndpoint(end2_0);
	conn0_61425638->makePathInvalid();
	conn0_378385232->makePathInvalid();
	end1_0 = Avoid::ConnEnd(shape0_1023802233, 20);
	end2_0 = Avoid::ConnEnd(junction0_526491597);
	conn0_117136925->setSourceEndpoint(end1_0);
	conn0_117136925->setDestEndpoint(end2_0);
	conn0_117136925->clearFixedRoute();
	conn0_224626788->makePathInvalid();
	end2_0 = Avoid::ConnEnd(junction0_30828132);
	conn0_446423927->setDestEndpoint(end2_0);
	conn0_446423927->clearFixedRoute();
	conn0_880789055->clearFixedRoute();
	end1_0 = Avoid::ConnEnd(shape0_1023802233, 13);
	conn0_11189244->setSourceEndpoint(end1_0);
	conn0_11189244->clearFixedRoute();
	conn0_605306624->makePathInvalid();
	conn0_61198110->makePathInvalid();
	conn0_323306544->makePathInvalid();
	conn0_2415000->makePathInvalid();
	junction0_144230940->setPositionFixed(false);
	junction0_30828132->setPositionFixed(false);
	junction0_526491597->setPositionFixed(false);
	end2_0 = Avoid::ConnEnd(junction0_144230940);
	conn0_61425638->setDestEndpoint(end2_0);
	conn0_61425638->makePathInvalid();
	conn0_378385232->makePathInvalid();
	end2_0 = Avoid::ConnEnd(junction0_526491597);
	conn0_117136925->setDestEndpoint(end2_0);
	conn0_117136925->makePathInvalid();
	conn0_224626788->makePathInvalid();
	end2_0 = Avoid::ConnEnd(junction0_30828132);
	conn0_446423927->setDestEndpoint(end2_0);
	conn0_446423927->makePathInvalid();
	conn0_880789055->makePathInvalid();
	conn0_11189244->makePathInvalid();
	junction0_24560921->setPositionFixed(false);
	end2_0 = Avoid::ConnEnd(junction0_24560921);
	conn0_605306624->setDestEndpoint(end2_0);
	conn0_605306624->makePathInvalid();
	conn0_61198110->makePathInvalid();
	conn0_323306544->makePathInvalid();
	conn0_2415000->makePathInvalid();
	router0->hyperedgeRerouter()->registerHyperedgeForRerouting(junction0_24560921);
	router0->hyperedgeRerouter()->registerHyperedgeForRerouting(junction0_526491597);
	router0->processTransaction();

	newanddeletedobjects_0 = router0->newAndDeletedObjectListsFromHyperedgeImprovement();
	router0->outputDiagram("output/treeRootCrash02-2");

	delete router0;
}

extern "C" int main(int argc, char* argv[])
{
	test();
	return 0;
}
